package stu.aistar.mapper;


import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import stu.aistar.model.pojo.User;

import java.util.List;


@Mapper
public interface UserMapper{
    @Select("select *from user where phone = #{phone}")
    User findUserByPhone(String phone);

    @Select("select *from user where phone = #{phone} and password = #{password} ")
    User findUserByPhoneAndPassword(@Param("phone") String phone, @Param("password") String password);


    List<User> findUsersByConditions(String username, String phone, String name);

    @Select("select *from user")
    List<User> findAll();

    @Insert("insert into user(phone,password,power) values(#{phone},#{password},#{power})")
    User save(User user);

    @Delete("delete from user where id = #{id}")
    int delteUserById(@Param("id") Integer id);

    int updateUser(User user);

    @Select("select *from user where phone = #{phone} and password = #{password} and power=1")
    User findAdminUser(@Param("phone") String phone, @Param("password") String password);

}
